package progetto6.jade;

public class FixedStrategy extends ScoreDependentStrategy {

	private static final long serialVersionUID = 772231932933036840L;
	private int step = 0;
	private final int nStep;
	private int iteration = 0;
	private boolean isSetted = false;
	
	public FixedStrategy(int n, int perc) {
		nStep = (n * perc) / 100;
	}

	@Override
	public Choice getNext() {
		if(iteration < nStep){
			switch (step) {
			case 0:
				lastChoice = Choice.D;
				step++;
				break;
			case 1:
				lastChoice = Choice.C;
				step = 0;
				break;
			default:
				break;
			}
		}else{
			if(isSetted){
				return lastChoice;
			}
			if(score[0] < score[1]){
				lastChoice = Choice.D;
			}else{
				lastChoice = Choice.C; 
			}
			isSetted = true;
		}
		iteration++;
		return lastChoice;
	}

	@Override
	public String toString() {
		return "FixedStrategy[nStep:"+nStep+"]";
	}

}
